import json

from flask import Blueprint
from flask import request
from flask import Response

from app.comm.db import db
from app.comm.db import jsonformater
from app.comm.pub import RestEntity
from app.comm.pub import class2dict

postservice = Blueprint('post', __name__,)

@postservice.route("/rest/system/post/list",methods=['POST','GET'])
def postList():  
    #dict1 = json.loads(a)
    tables=db.session.execute("select post_id postId,post_code postCode,post_name postName,status,create_time createTime,remark from sys_post").fetchall()
    datas= [dict(r) for r in tables] 
    result=RestEntity(0,0,datas,"登陆成功！")
    return json.dumps(class2dict(result), default=jsonformater)
 
    #return json.dumps(dict1)         